<div style="border: 3px solid gray; float: left; padding:5px;">
<?php
	myPrint($_SESSION, '$_SESSION');
	myPrint( Form::$values, 'Form::$values'); myPrint( Form::$errors, 'Form::$errors');
	$parse_url = Page::parse_url( $_SERVER['REQUEST_URI'] ); 
	
	//$regex='#/login#';
?>
	<div id='auth_div'>
	<?php
		if(!empty($_SESSION['user']['sign'])) {
			$out = 'Hello, '.$_SESSION['user']['ud_name'].' '.$_SESSION['user']['ud_surname'].'<br/>'.
				( IS_ADMIN ? '<a href="/admin" data-noajax="1" onclick="window.open(this.href);return false;">Админка</a>' : '' ).
				' <a class="pseudolink" id="logout_link" href="\">Выйти</a>';
			echo $out;
		} else {
			echo '&nbsp;';
			if( !empty($_SESSION['lastURI']) && $_SESSION['lastURI']!='/login' )
			echo '<span class="pseudolink"  onclick="document.getElementById(\'auth_form\').style.display=\'block\'">Войти</a>';		
		} 

		
		//echo serialize( array('1') );|| strstr($parse_url['path'], '/login')
	?>
	</div>
</div>
<div style="clear:both;"></div>

<div id="auth_form" style="display:<?php 
echo (count( Form::errorsAll('login_form_') )>0 || $_SESSION['lastURI']=='/login') ?'block': 'none' 
?>; position:fixed;top:40%;left:40%;width_:220px;background-color:white; border: 3px solid gray;padding:5px;">
	<?php if( !empty($_SESSION['lastURI']) && $_SESSION['lastURI']!='/login' ) {?>
		<div style="cursor:pointer;float:right;color:red;" class="close_button" onclick="this.parentNode.style.display='none';"></div>
	<?php } ?>
	<div id="login_form">
		<!--Module::Auth()-->
	</div>	
</div>

<script type="text/javascript">
(function(){
	var id = 'logout_link';
		elem = document.getElementById( id );
	if(!elem || elem.innerHTML==undefined) {
		//debug( id+' isn\'t a HTMLElement or not a single', id );
		return;
	}
	
	elem.onclick = function( event ){
		/* logout Request */
		ajaxRequest({ 
			url: '/ajax/'+'login_form_'+'.php',
			data: {logout:1},
			dataType: "json",
			type: "post"
		});
		/* redirect */
		ajaxRequest( this.href, { dataType:'json'});
		/* предотвращ. действие по умолчанию */
		return false;
	}		
})();
</script>